package com.tl.sun.model;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by bin on 16/3/7.
 */
public class PayInfo {

    public String appId;    // 微信分配的APPID:wxbc43433cc7c17b81
    public String partnerId; // 微信支付分配的商户号:1318225801
    public String prepayId; // 微信返回的支付交易会话ID
    public String nonceStr; // 随机字符串
    public String timeStamp;    // 时间戳
    public String packageValue;  // 扩展字段
    public String sign;   // 签名



    public static void PayInfoParser(JSONObject infoJson, PayInfo payInfo)
            throws JSONException {
        payInfo.appId = infoJson.optString("appid");
        payInfo.partnerId = infoJson.optString("partnerid");
        payInfo.prepayId = infoJson.optString("prepayid");
        payInfo.nonceStr = infoJson.optString("noncestr");
        payInfo.timeStamp = infoJson.optString("timestamp");
        payInfo.packageValue = "Sign=WXPay";
        payInfo.sign = infoJson.optString("sign");
//        PayManager.sCallbackUrl = infoJson.optString("callback_url");
//        PayManager.sCallbackErrorUrl = infoJson.optString("callback_url_error");
    }

    @Override
    public String toString() {
        return "PayInfo{" +
                "appId='" + appId + '\'' +
                ", partnerId='" + partnerId + '\'' +
                ", prepayId='" + prepayId + '\'' +
                ", nonceStr='" + nonceStr + '\'' +
                ", timeStamp='" + timeStamp + '\'' +
                ", packageValue='" + packageValue + '\'' +
                ", sign='" + sign + '\'' +
                '}';
    }
}
